<template>
  <div class="page-common-layout">
    <div class="page-common-content">
      <tool-bar
        @search="$refs.table.refresh(true)"
        @reset="() => {
          queryParam = {}, $refs.table.refresh(true)
        }"
      >
        <template slot="toolBtn" slot-scope="scope">
          <a-button
            class="cu-btn-primary"
            icon="plus"
            @click="
              (e) => {
                handleAdd();
              }
            "
            v-action:categoryAddDialog
            >{{$ct("add","新增")}}</a-button
          >
        </template>
        <template slot="toolForm">
				  <a-form-item label="名称">
				    <a-input v-model="queryParam.text" placeholder="名称" />
				  </a-form-item>
				</template>
      </tool-bar>

			<DataGrid
				ref="table"
				:url="url"
				:columns="columns"
				rowKey="uuid"
        :queryParam="queryParam"
        :showRowSelect="false"
			>
				<span slot="renderAction" slot-scope="{ text, record, index }">
				  <template>
				    <a @click="handleEdit(record)">{{$ct("edit","编辑")}}</a>
				    <span class="action-margin"></span>
				    <a @click="handleSub(record)" class="action-delete">{{$ct("delete","删除")}}</a>
				  </template>
				</span>
			</DataGrid>

      <!-- <api /> -->
      <edit-form
        ref="createModal"
        :type="key"
        :visible="visible"
        :loading="confirmLoading"
        :model="mdl"
        @cancel="handleCancel()"
        @ok="handleOk()"
      />
    </div>
  </div>
</template>

<script>
import { DataGrid } from "@/components";
import { dataGridMixin } from "@/mixins/dataGridMixin";
import editForm from "./edit.vue";
export default {
  name: "Table",
  mixins: [dataGridMixin],
  components: {
    DataGrid,
    editForm,
  },
  data() {
    return {
      key: "0",
      confirmLoading: false,
      visible: false,
      mdl: null,
      rows: null,
      selectedRowKeys: [],
      selectedRows: [],
      columns: [
        {
          title: "名称",
          align: "left",
          dataIndex: "text",
          langCode: "name",
        },
        {
          title: "创建时间",
          align: "left",
          dataIndex: "createTime",
          langCode: "createTime",
        },
        {
          title: "创建者",
          align: "left",
          dataIndex: "creator",
          langCode: "createdBy"
        },
        {
          title: "排序",
          dataIndex: "sort",
          width: 80,
        },
        {
          title: "操作",
          width: 100,
          align: "center",
          dataIndex: "action",
          scopedSlots: { customRender: "renderAction" },
        },
      ],
      queryParam: {},
      url: {
        getPageSet: "/system/channel/getPageSetData",
        save: "/system/channel/save",
        update: "/system/channel/update",
        deleteBatch: "/system/channel/deleteBatch"
      }
    };
  },
  filters: {
    stateFilter(val) {
      const stateMap = {
        0: "否",
        1: "是",
      };
      return stateMap[val.text];
    },
  },
  computed: {
    disabled() {
      if (!this.selectedRows.find((item) => item.levelId == 1))
        return false;
      else return true;
    },
  },
  created() {},
  methods: {},
};
</script>

<style scoped lang="less">
// .table {
// 	background-color: @base-bg-color;
// 	padding: calc();
// }
</style>
